<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改学生</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
        .flex_center_row{
            display: flex;
            flex-direction: row;
            justify-content: center;
        }
    </style>
</head>
<body>
    <div class="layui-row layui-col-space15 flex_center_row">
        <div class="layui-col-md6">
          <div class="layui-panel">
            <div style="padding: 30px;">
                <!-- 内容 -->
                <div class="layui-form layuimini-form" lay-filter="student" >
                    <div class="layui-form-item" style="display: none;">
                        <label class="layui-form-label required">class_id</label>
                        <div class="layui-input-block">
                            <input type="text" name="class_id" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: none;">
                        <label class="layui-form-label required">class_id</label>
                        <div class="layui-input-block">
                            <input type="text" name="u_id" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">学院名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="college" lay-verify="required" lay-reqtext="学院名称不能为空" placeholder="请输入学院名称" value="" class="layui-input">
                            <tip>填写自己管理学院的名称。--例如：软件学院</tip>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">学号</label>
                        <div class="layui-input-block">
                            <input type="text" name="stdudent_number" lay-verify="required" lay-reqtext="学号不能为空" placeholder="请输入学号" value="" class="layui-input">
                            <tip>填写自己管理班级的名称。--例如：软件2001班</tip>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="student_name" lay-verify="required" lay-reqtext="姓名不能为空" placeholder="请输入姓名" value="" class="layui-input">
                            <tip>学生姓名--中文</tip>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">联系方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="phone" lay-verify="required" lay-reqtext="联系方式不能为空" placeholder="请输入联系方式" value="" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                        </div>
                    </div>
                </div>
            </div>
          </div>   
        </div>
    </div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../../var/var.js"></script>
<script>
    var re = layui.data("select_obj")["select_obj"]
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;
            form.val("student",{
                "class_id": re.class_id,
                "u_id": re.user_id,
                "college": re.college,
                "stdudent_number": re.student_number,
                "student_name":re.student_name,
                "phone":re.phone
            })
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = JSON.stringify(data.field)
            // console.log(index)
            $.ajax({
                    url:UrlStr+'/instructor/student/update',
                    data: index,
                    headers: {Authorization: layui.data("token")["token"]},
                    type:"post",
                    dataType:"json",
                 success:function(data){
                            if(data.code==1012){
                                layer.msg("学号已存在")
                            }else if (data.code==1000){
                                layer.msg('修改成功');
                            }    
                        }
                    })
        });

    });
</script>
</body>
</html>